
package gui;

import business.Cliente;
import business.Reserva;
import java.text.ParseException;
import java.util.Calendar;
import javax.swing.JOptionPane;


public class Cliente_Principal extends javax.swing.JPanel {

    private static Cliente_Principal instance;

    void setjTextFieldClientePrincipalNome(String nome) {
        jTextFieldClientePrincipalNome.setText(nome);
    }

    void setjTextFieldClientePrincipalCPF(String cpf) {
        jTextFieldClientePrincipalCPF.setText(cpf);
    }

    void setjTextFieldClientePrincipalCEP(String cep) {
        jTextFieldClientePrincipalCEP.setText(cep);
    }

    void setjTextFieldClientePrincipalNumero(String numero) {
        jTextFieldClientePrincipalNumero.setText(numero);
    }
    
    public enum StatusClientePrincipal{
        scInserindo,
        scPesquisado
    }
    
    private StatusClientePrincipal sStatus;
    
    public Cliente_Principal() {
        sStatus = StatusClientePrincipal.scInserindo;
                initComponents();
        /*jTextFieldClientePrincipalCPF.setEnabled(false);
        jTextFieldClientePrincipalRG.setEnabled(false);
        jTextFieldClientePrincipalDataNascimento.setEnabled(false);
        jTextFieldClientePrincipalEndereco.setEnabled(false);
        jTextFieldClientePrincipalNumero.setEnabled(false);
        jTextFieldClientePrincipalComplemento.setEnabled(false);
        jTextFieldClientePrincipalCEP.setEnabled(false);
        jTextFieldClientePrincipalCNH.setEnabled(false);
        jTextFieldClientePrincipalValidadeCNH.setEnabled(false);*/

    }

    public static Cliente_Principal getInstance(){
        if (instance == null)
            instance = new Cliente_Principal();
        return instance;
    }

    public StatusClientePrincipal getsStatus() {
        return sStatus;
    }

    public void setsStatus(StatusClientePrincipal sStatus) {
        this.sStatus = sStatus;
    }


    public void setjTextFieldClientePrincipalCNH(String cnh) {
        this.jTextFieldClientePrincipalCNH.setText(cnh);
    }

    public void setjTextFieldClientePrincipalComplemento(String complemento) {
        this.jTextFieldClientePrincipalComplemento.setText(complemento);
    }

    public void setjTextFieldClientePrincipalDataNascimento(String dataNascimento) {
        this.jTextFieldClientePrincipalDataNascimento.setText(dataNascimento);
    }

    public void setjTextFieldClientePrincipalEndereco(String endereco) {
        this.jTextFieldClientePrincipalEndereco.setText(endereco);
    }

    public void setjTextFieldClientePrincipalRG(String rg) {
        this.jTextFieldClientePrincipalRG.setText(rg);
    }
    
    void setjTextFieldClientePrincipalValidadeCNH(String validadeCNH) {
        this.jTextFieldClientePrincipalValidadeCNH.setText(validadeCNH);
    }
    public void setjTextFieldClientePrincipalCPFEnabled(boolean edit) {
        this.jTextFieldClientePrincipalCPF.setEnabled(edit);
        
    }
       public void setjTextFieldClientePrincipalRGEnabled(boolean edit) {
        this.jTextFieldClientePrincipalRG.setEnabled(edit);
    }

    public void setjTextFieldClientePrincipalNomeEnabled(boolean edit) {
        this.jTextFieldClientePrincipalNome.setEnabled(edit);
    }
       public void setjTextFieldClientePrincipalDataNascimentoEnabled(boolean edit) {
        this.jTextFieldClientePrincipalDataNascimento.setEnabled(edit);
    }



    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jLabelClientePrincipalCPF = new javax.swing.JLabel();
        jLabelClientePrincipalRG = new javax.swing.JLabel();
        jLabelClientePrincipalNome = new javax.swing.JLabel();
        jLabelClientePrincipalDataNascimento = new javax.swing.JLabel();
        jLabelClientePrincipalComplemento = new javax.swing.JLabel();
        jLabelClientePrincipalNumero = new javax.swing.JLabel();
        jTextFieldClientePrincipalRG = new javax.swing.JTextField();
        jTextFieldClientePrincipalNome = new javax.swing.JTextField();
        jTextFieldClientePrincipalComplemento = new javax.swing.JTextField();
        jTextFieldClientePrincipalNumero = new javax.swing.JTextField();
        jTextFieldClientePrincipalCPF = new javax.swing.JTextField();
        jTextFieldClientePrincipalDataNascimento = new javax.swing.JTextField();
        jLabelClientePrincipalEndereco = new javax.swing.JLabel();
        jTextFieldClientePrincipalEndereco = new javax.swing.JTextField();
        jLabelClientePrincipalCEP = new javax.swing.JLabel();
        jTextFieldClientePrincipalCEP = new javax.swing.JTextField();
        jLabelClientePrincipalCNH = new javax.swing.JLabel();
        jTextFieldClientePrincipalCNH = new javax.swing.JTextField();
        jLabelClientePrincipalValidadeCNH = new javax.swing.JLabel();
        jTextFieldClientePrincipalValidadeCNH = new javax.swing.JTextField();
        jButtonClientePrincipalSalvar = new javax.swing.JButton();
        jButtonClientePrincipalEditar = new javax.swing.JButton();
        jButtonClientePrincipalPesquisar = new javax.swing.JButton();
        jButtonClientePrincipalNovo = new javax.swing.JButton();
        jButtonClientePrincipalDeletar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("gui/Bundle"); // NOI18N
        jLabel2.setText(bundle.getString("Cliente_Principal.jLabel2.text")); // NOI18N

        jLabelClientePrincipalCPF.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalCPF.text")); // NOI18N

        jLabelClientePrincipalRG.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalRG.text")); // NOI18N

        jLabelClientePrincipalNome.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalNome.text")); // NOI18N

        jLabelClientePrincipalDataNascimento.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalDataNascimento.text")); // NOI18N

        jLabelClientePrincipalComplemento.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalComplemento.text")); // NOI18N

        jLabelClientePrincipalNumero.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalNumero.text")); // NOI18N

        jTextFieldClientePrincipalRG.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalRGFocusLost(evt);
            }
        });

        jTextFieldClientePrincipalNome.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalNomeFocusLost(evt);
            }
        });

        jTextFieldClientePrincipalComplemento.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalComplementoFocusLost(evt);
            }
        });

        jTextFieldClientePrincipalNumero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldClientePrincipalNumeroActionPerformed(evt);
            }
        });
        jTextFieldClientePrincipalNumero.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalNumeroFocusLost(evt);
            }
        });

        jTextFieldClientePrincipalCPF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldClientePrincipalCPFActionPerformed(evt);
            }
        });
        jTextFieldClientePrincipalCPF.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalCPFFocusLost(evt);
            }
        });

        jTextFieldClientePrincipalDataNascimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldClientePrincipalDataNascimentoActionPerformed(evt);
            }
        });
        jTextFieldClientePrincipalDataNascimento.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalDataNascimentoFocusLost(evt);
            }
        });

        jLabelClientePrincipalEndereco.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalEndereco.text")); // NOI18N

        jTextFieldClientePrincipalEndereco.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldClientePrincipalEnderecoActionPerformed(evt);
            }
        });
        jTextFieldClientePrincipalEndereco.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalEnderecoFocusLost(evt);
            }
        });

        jLabelClientePrincipalCEP.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalCEP.text")); // NOI18N

        jTextFieldClientePrincipalCEP.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalCEPFocusLost(evt);
            }
        });

        jLabelClientePrincipalCNH.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalCNH.text")); // NOI18N

        jTextFieldClientePrincipalCNH.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalCNHFocusLost(evt);
            }
        });

        jLabelClientePrincipalValidadeCNH.setText(bundle.getString("Cliente_Principal.jLabelClientePrincipalValidadeCNH.text")); // NOI18N

        jTextFieldClientePrincipalValidadeCNH.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldClientePrincipalValidadeCNHFocusLost(evt);
            }
        });

        jButtonClientePrincipalSalvar.setText(bundle.getString("Cliente_Principal.jButtonClientePrincipalSalvar.text")); // NOI18N
        jButtonClientePrincipalSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonClientePrincipalSalvarActionPerformed(evt);
            }
        });

        jButtonClientePrincipalEditar.setText(bundle.getString("Cliente_Principal.jButtonClientePrincipalEditar.text")); // NOI18N
        jButtonClientePrincipalEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonClientePrincipalEditarActionPerformed(evt);
            }
        });

        jButtonClientePrincipalPesquisar.setText(bundle.getString("Cliente_Principal.jButtonClientePrincipalPesquisar.text")); // NOI18N
        jButtonClientePrincipalPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonClientePrincipalPesquisarActionPerformed(evt);
            }
        });

        jButtonClientePrincipalNovo.setText(bundle.getString("Cliente_Principal.jButtonClientePrincipalNovo.text")); // NOI18N
        jButtonClientePrincipalNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonClientePrincipalNovoActionPerformed(evt);
            }
        });

        jButtonClientePrincipalDeletar.setText(bundle.getString("Cliente_Principal.jButtonClientePrincipalDeletar.text")); // NOI18N
        jButtonClientePrincipalDeletar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonClientePrincipalDeletarActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel1.setText(bundle.getString("Cliente_Principal.jLabel1.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButtonClientePrincipalPesquisar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButtonClientePrincipalEditar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButtonClientePrincipalSalvar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButtonClientePrincipalNovo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButtonClientePrincipalDeletar, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(31, 31, 31)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelClientePrincipalNome)
                                    .addComponent(jLabelClientePrincipalCPF))
                                .addGap(41, 41, 41)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jTextFieldClientePrincipalCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelClientePrincipalRG)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextFieldClientePrincipalRG, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelClientePrincipalDataNascimento)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextFieldClientePrincipalDataNascimento, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE))
                                    .addComponent(jTextFieldClientePrincipalNome, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelClientePrincipalEndereco)
                                    .addComponent(jLabelClientePrincipalNumero))
                                .addGap(23, 23, 23)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jTextFieldClientePrincipalNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelClientePrincipalComplemento)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextFieldClientePrincipalComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(23, 23, 23)
                                        .addComponent(jLabelClientePrincipalCEP)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jTextFieldClientePrincipalCEP, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE))
                                    .addComponent(jTextFieldClientePrincipalEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 575, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 387, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelClientePrincipalCNH)
                                    .addComponent(jLabelClientePrincipalValidadeCNH))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldClientePrincipalCNH, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                                    .addComponent(jTextFieldClientePrincipalValidadeCNH, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(432, 432, 432)
                        .addComponent(jLabel1)))
                .addContainerGap(16, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel1)
                .addGap(67, 67, 67)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonClientePrincipalNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonClientePrincipalSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonClientePrincipalEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonClientePrincipalPesquisar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonClientePrincipalDeletar, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelClientePrincipalNome)
                            .addComponent(jTextFieldClientePrincipalNome, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelClientePrincipalCPF)
                            .addComponent(jTextFieldClientePrincipalCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelClientePrincipalRG)
                            .addComponent(jTextFieldClientePrincipalRG, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldClientePrincipalDataNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelClientePrincipalDataNascimento))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelClientePrincipalEndereco)
                            .addComponent(jTextFieldClientePrincipalEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelClientePrincipalNumero)
                            .addComponent(jTextFieldClientePrincipalNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelClientePrincipalComplemento)
                            .addComponent(jTextFieldClientePrincipalComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelClientePrincipalCEP)
                            .addComponent(jTextFieldClientePrincipalCEP, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldClientePrincipalCNH, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelClientePrincipalCNH))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldClientePrincipalValidadeCNH, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelClientePrincipalValidadeCNH))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonClientePrincipalEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClientePrincipalEditarActionPerformed
       if (sStatus != StatusClientePrincipal.scPesquisado)
           JOptionPane.showMessageDialog(this,"Pesquise um cliente para editá-lo.");
       else
       {
                    
                Cliente.alterarCliente(jTextFieldClientePrincipalCPF.getText(),jTextFieldClientePrincipalRG.getText(),
                    jTextFieldClientePrincipalNome.getText(),jTextFieldClientePrincipalDataNascimento.getText(),
                    jTextFieldClientePrincipalCEP.getText(),jTextFieldClientePrincipalEndereco.getText(),
                    jTextFieldClientePrincipalNumero.getText(),jTextFieldClientePrincipalComplemento.getText(),
                    jTextFieldClientePrincipalCNH.getText(),jTextFieldClientePrincipalValidadeCNH.getText());

                    jTextFieldClientePrincipalNome.setEnabled(true);
                    jTextFieldClientePrincipalCPF.setEnabled(true);
                    jTextFieldClientePrincipalRG.setEnabled(true);
                    jTextFieldClientePrincipalDataNascimento.setEnabled(true);
                    sStatus = StatusClientePrincipal.scInserindo;
                   //    jTextFieldClientePrincipalDataNascimento.setEnabled(false);
       // jTextFieldClientePrincipalEndereco.setEnabled(false);
       // jTextFieldClientePrincipalNumero.setEnabled(false);
       // jTextFieldClientePrincipalComplemento.setEnabled(false);
       // jTextFieldClientePrincipalCEP.setEnabled(false);
      //  jTextFieldClientePrincipalCNH.setEnabled(false);
      //  jTextFieldClientePrincipalValidadeCNH.setEnabled(false);
                
                    LimpaTela();
       }
    }//GEN-LAST:event_jButtonClientePrincipalEditarActionPerformed

    private void jButtonClientePrincipalPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClientePrincipalPesquisarActionPerformed
       Cliente_Pesquisar frame=new Cliente_Pesquisar();
                   // jTextFieldClientePrincipalEndereco.setEnabled(true);
                   // jTextFieldClientePrincipalNumero.setEnabled(true);
                   // jTextFieldClientePrincipalComplemento.setEnabled(true);
                   //  jTextFieldClientePrincipalCEP.setEnabled(true);
                   //   jTextFieldClientePrincipalCNH.setEnabled(true);
                   //    jTextFieldClientePrincipalValidadeCNH.setEnabled(true);
       frame.setVisible(true);        
       
    }//GEN-LAST:event_jButtonClientePrincipalPesquisarActionPerformed

    private void jButtonClientePrincipalSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClientePrincipalSalvarActionPerformed

        if (sStatus == StatusClientePrincipal.scInserindo){
             if (jTextFieldClientePrincipalCPF.getText().isEmpty()    ||
                jTextFieldClientePrincipalNome.getText().isEmpty()   || jTextFieldClientePrincipalDataNascimento.getText().isEmpty() ||
                jTextFieldClientePrincipalCEP.getText().isEmpty()    || jTextFieldClientePrincipalEndereco.getText().isEmpty() ||
                jTextFieldClientePrincipalNumero.getText().isEmpty() || jTextFieldClientePrincipalComplemento.getText().isEmpty() ||
                jTextFieldClientePrincipalCNH.getText().isEmpty()    || jTextFieldClientePrincipalValidadeCNH.getText().isEmpty()){
                    JOptionPane.showMessageDialog(this,"Existem campos em branco!");
                    return;
        }

        if (Cliente.ClienteExiste(jTextFieldClientePrincipalCPF.getText())){
            JOptionPane.showMessageDialog(this, "Cliente já existe.");
            return;
        }                
                    
                Cliente.insertCliente(jTextFieldClientePrincipalCPF.getText(),jTextFieldClientePrincipalRG.getText(),
                        jTextFieldClientePrincipalNome.getText(),jTextFieldClientePrincipalDataNascimento.getText(),
                        jTextFieldClientePrincipalCEP.getText(),jTextFieldClientePrincipalEndereco.getText(),
                        jTextFieldClientePrincipalNumero.getText(),jTextFieldClientePrincipalComplemento.getText(),
                        jTextFieldClientePrincipalCNH.getText(),jTextFieldClientePrincipalValidadeCNH.getText());
                            this.LimpaTela();
                                    /*jTextFieldClientePrincipalCPF.setEnabled(false);
                                     jTextFieldClientePrincipalRG.setEnabled(false);
        jTextFieldClientePrincipalDataNascimento.setEnabled(false);
        jTextFieldClientePrincipalEndereco.setEnabled(false);
        jTextFieldClientePrincipalNumero.setEnabled(false);
        jTextFieldClientePrincipalComplemento.setEnabled(false);
        jTextFieldClientePrincipalCEP.setEnabled(false);
        jTextFieldClientePrincipalCNH.setEnabled(false);
        jTextFieldClientePrincipalValidadeCNH.setEnabled(false);*/
                }
         
        else{
                  JOptionPane.showMessageDialog(this, "Para inserir o num novo cliente, clique em novo.");      
        }
    }//GEN-LAST:event_jButtonClientePrincipalSalvarActionPerformed
    private void LimpaTela(){
        jTextFieldClientePrincipalCPF.setText(""); 
        jTextFieldClientePrincipalRG.setText(""); 
        jTextFieldClientePrincipalNome.setText(""); 
        jTextFieldClientePrincipalDataNascimento.setText(""); 
        jTextFieldClientePrincipalCEP.setText(""); 
        jTextFieldClientePrincipalEndereco.setText(""); 
        jTextFieldClientePrincipalNumero.setText(""); 
        jTextFieldClientePrincipalComplemento.setText(""); 
        jTextFieldClientePrincipalValidadeCNH.setText(""); 
        jTextFieldClientePrincipalCNH.setText(""); 
        
    }
    private void jButtonClientePrincipalDeletarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClientePrincipalDeletarActionPerformed
        if (sStatus != StatusClientePrincipal.scPesquisado)
           JOptionPane.showMessageDialog(this,"Pesquise um cliente para deletá-lo.");
        else{
            Cliente.deleteClientePeloCPF(jTextFieldClientePrincipalCPF.getText());
            LimpaTela();
            jTextFieldClientePrincipalNome.setEnabled(true);
            jTextFieldClientePrincipalCPF.setEnabled(true);
            jTextFieldClientePrincipalRG.setEnabled(true);
            jTextFieldClientePrincipalDataNascimento.setEnabled(true);
            sStatus = StatusClientePrincipal.scInserindo;
        }
        
      
    }//GEN-LAST:event_jButtonClientePrincipalDeletarActionPerformed

    private void jButtonClientePrincipalNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClientePrincipalNovoActionPerformed
       LimpaTela();

        sStatus = StatusClientePrincipal.scInserindo;
    }//GEN-LAST:event_jButtonClientePrincipalNovoActionPerformed

    private void jTextFieldClientePrincipalCEPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalCEPFocusLost
        String cep = jTextFieldClientePrincipalCEP.getText(); 
        if (cep.length() != 8 && cep.length() != 0){
            JOptionPane.showMessageDialog(this,"Valor de CEP Inválido.");
            jTextFieldClientePrincipalCEP.requestFocus();
            jTextFieldClientePrincipalCEP.selectAll();
            return;
        }
        for (int i = 0; i < cep.length(); i++){
            if (!Character.isDigit(cep.charAt(i))){
                JOptionPane.showMessageDialog(this,"Valor de CEP Inválido.");
                jTextFieldClientePrincipalCEP.requestFocus();
                jTextFieldClientePrincipalCEP.selectAll();
                return;
              
            }
        }
        
        jTextFieldClientePrincipalCNH.setEnabled(true);
      
    }//GEN-LAST:event_jTextFieldClientePrincipalCEPFocusLost

    private void jTextFieldClientePrincipalNomeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalNomeFocusLost
        String nome = jTextFieldClientePrincipalNome.getText();
        if (nome.length() > 30){
            JOptionPane.showMessageDialog(this, "Nome inválido.");
            jTextFieldClientePrincipalNome.requestFocus();
            jTextFieldClientePrincipalNome.selectAll();
            return;
        }
        for (int i = 0; i < nome.length(); i++)
            if (!Character.isAlphabetic(nome.charAt(i)) && nome.charAt(i)!=' '){ //Arrumei pois antes nao estava permitindo insercao de nomes e sobrenomes...Augusto
                JOptionPane.showMessageDialog(this, "Nome inválido.");
                jTextFieldClientePrincipalNome.requestFocus();
                jTextFieldClientePrincipalNome.selectAll(); 
                return;
            }
       jTextFieldClientePrincipalCPF.setEnabled(true); 
    }//GEN-LAST:event_jTextFieldClientePrincipalNomeFocusLost

    private void jTextFieldClientePrincipalNumeroFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalNumeroFocusLost
        String numero = jTextFieldClientePrincipalNumero.getText();
        for (int i = 0; i < numero.length(); i++)
            if (!Character.isDigit(numero.charAt(i))){
                JOptionPane.showMessageDialog(this, "Numero inválido.");
                jTextFieldClientePrincipalNumero.requestFocus();
                jTextFieldClientePrincipalNumero.selectAll(); 
                return;
            }
               jTextFieldClientePrincipalComplemento.setEnabled(true); 
    }//GEN-LAST:event_jTextFieldClientePrincipalNumeroFocusLost

    private void jTextFieldClientePrincipalCPFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalCPFActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalCPFActionPerformed

    private void jTextFieldClientePrincipalCPFFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalCPFFocusLost
     
        String CPF= jTextFieldClientePrincipalCPF.getText();
        
        if(CPF.length()!=11 || !Cliente.validaCPF(CPF) || Cliente.ClienteExiste(CPF) )
        {       JOptionPane.showMessageDialog(this, "CPF inválido.");
                jTextFieldClientePrincipalNumero.requestFocus();
                jTextFieldClientePrincipalNumero.selectAll(); 
                return;}
        
        jTextFieldClientePrincipalRG.setEnabled(true);

        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalCPFFocusLost

    private void jTextFieldClientePrincipalRGFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalRGFocusLost
        String RG=jTextFieldClientePrincipalRG.getText();
        
          for (int i = 0; i < RG.length(); i++)
            if (!Character.isDigit(RG.charAt(i))){
                JOptionPane.showMessageDialog(this, "RG inválido.");
                jTextFieldClientePrincipalRG.requestFocus();
                jTextFieldClientePrincipalRG.selectAll(); 
                return;
            }      

            jTextFieldClientePrincipalDataNascimento.setEnabled(true);
    }//GEN-LAST:event_jTextFieldClientePrincipalRGFocusLost

    private void jTextFieldClientePrincipalDataNascimentoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalDataNascimentoFocusLost
       String Data=jTextFieldClientePrincipalDataNascimento.getText();
     
         if(!Cliente.MaiorDeIdade(Data)||Data.equals("")||!Cliente.isDate(Data))
                {        JOptionPane.showMessageDialog(this, "Data Inválida.");
                      jTextFieldClientePrincipalDataNascimento.requestFocus();
                      jTextFieldClientePrincipalDataNascimento.selectAll();
                      return;
                }
         
      jTextFieldClientePrincipalEndereco.setEnabled(true);

        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalDataNascimentoFocusLost

    private void jTextFieldClientePrincipalEnderecoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalEnderecoFocusLost

        String end= jTextFieldClientePrincipalEndereco.getText();
        
        if(end.equals(""))
        {        JOptionPane.showMessageDialog(this, "Endereco Inválido.");
                      jTextFieldClientePrincipalEndereco.requestFocus();
                      jTextFieldClientePrincipalEndereco.selectAll();
                      return;
        }
        jTextFieldClientePrincipalNumero.setEnabled(true);

        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalEnderecoFocusLost

    private void jTextFieldClientePrincipalComplementoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalComplementoFocusLost

        jTextFieldClientePrincipalCEP.setEnabled(true);

        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalComplementoFocusLost

    private void jTextFieldClientePrincipalCNHFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalCNHFocusLost
        String CNH= jTextFieldClientePrincipalCNH.getText();
        
                
         if(CNH.length()!=11)
         {
                JOptionPane.showMessageDialog(this, "CNH inválido.");
                jTextFieldClientePrincipalCNH.requestFocus();
                jTextFieldClientePrincipalCNH.selectAll(); 
                return;
         }       
                
         for (int i = 0; i < CNH.length(); i++)
            if (!Character.isDigit(CNH.charAt(i))){
                JOptionPane.showMessageDialog(this, "CNH inválido.");
                jTextFieldClientePrincipalCNH.requestFocus();
                jTextFieldClientePrincipalCNH.selectAll(); 
                return;
            } 
         jTextFieldClientePrincipalValidadeCNH.setEnabled(true);        
     
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalCNHFocusLost

    private void jTextFieldClientePrincipalValidadeCNHFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalValidadeCNHFocusLost
    String Data=jTextFieldClientePrincipalValidadeCNH.getText();
    
    if(!Cliente.CNHValidade(Data))
{
              JOptionPane.showMessageDialog(this, "Data inválido.");
                jTextFieldClientePrincipalValidadeCNH.requestFocus();
                jTextFieldClientePrincipalValidadeCNH.selectAll(); 
                return;
            }         
        
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalValidadeCNHFocusLost

    private void jTextFieldClientePrincipalEnderecoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalEnderecoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalEnderecoActionPerformed

    private void jTextFieldClientePrincipalNumeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalNumeroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalNumeroActionPerformed

    private void jTextFieldClientePrincipalDataNascimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldClientePrincipalDataNascimentoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldClientePrincipalDataNascimentoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonClientePrincipalDeletar;
    private javax.swing.JButton jButtonClientePrincipalEditar;
    private javax.swing.JButton jButtonClientePrincipalNovo;
    private javax.swing.JButton jButtonClientePrincipalPesquisar;
    private javax.swing.JButton jButtonClientePrincipalSalvar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabelClientePrincipalCEP;
    private javax.swing.JLabel jLabelClientePrincipalCNH;
    private javax.swing.JLabel jLabelClientePrincipalCPF;
    private javax.swing.JLabel jLabelClientePrincipalComplemento;
    private javax.swing.JLabel jLabelClientePrincipalDataNascimento;
    private javax.swing.JLabel jLabelClientePrincipalEndereco;
    private javax.swing.JLabel jLabelClientePrincipalNome;
    private javax.swing.JLabel jLabelClientePrincipalNumero;
    private javax.swing.JLabel jLabelClientePrincipalRG;
    private javax.swing.JLabel jLabelClientePrincipalValidadeCNH;
    private javax.swing.JTextField jTextFieldClientePrincipalCEP;
    private javax.swing.JTextField jTextFieldClientePrincipalCNH;
    private javax.swing.JTextField jTextFieldClientePrincipalCPF;
    private javax.swing.JTextField jTextFieldClientePrincipalComplemento;
    private javax.swing.JTextField jTextFieldClientePrincipalDataNascimento;
    private javax.swing.JTextField jTextFieldClientePrincipalEndereco;
    private javax.swing.JTextField jTextFieldClientePrincipalNome;
    private javax.swing.JTextField jTextFieldClientePrincipalNumero;
    private javax.swing.JTextField jTextFieldClientePrincipalRG;
    private javax.swing.JTextField jTextFieldClientePrincipalValidadeCNH;
    // End of variables declaration//GEN-END:variables
}
